package com.shuinfo.core;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ApiResult {

    /**
     * 相关信息
     **/
    private String msg;

    /**
     * 请求状态 200-成功 400-失败
     **/
    private Integer code;

    /**
     * 返回结果
     **/
    private Object data;

    public static ApiResult ok() {
        return new ApiResult(null, 200, null);
    }

    public static ApiResult ok(Object data) {
        return new ApiResult(null, 200, data);
    }

    public static ApiResult ok(List<?> data) {
        return new ApiResult(null, 200, data);
    }

    public static ApiResult fail(String msg) {
        return new ApiResult(msg, 200, null);
    }
}

